package com.link.base.base.knowledge.dao.mybatis.mapper;

import com.link.base.base.knowledge.model.Knowledge;
import com.link.core.basic.dao.mapper.BasicMapper;

import java.util.List;

/**
 * @author unknown
 * @date unknown
 * @desc 知识库处理
 */
public interface KnowledgeMapper extends BasicMapper<Knowledge> {

    /**
     * 知识库统计
     * @param entity 知识库对象
     * @return Knowledge
     */
    Knowledge countCollById(Knowledge entity);

    /**
     * 获取知识库树根
     * @param entity 知识库对象
     * @return Knowledge
     */
    Knowledge queryRootByShareId(Knowledge entity);

    /**
     * 获取corpid publicTag
     * @param entity 知识库对象
     * @return Knowledge
     */
    Knowledge queryCorpById(Knowledge entity);

    /**
     * 获取根节点
     * @param knowledge 知识库对象
     * @return List Knowledge
     */
    List<Knowledge> queryRoot(Knowledge knowledge);

    /**
     * 获取树
     * @param t 知识库对象
     * @return List Knowledge
     */
    List<Knowledge> queryTreeByRoot(Knowledge t);

    /**
     * 获取知识库
     * @param entity 知识库对象
     * @return List Knowledge
     */
    List<Knowledge> queryLeafByNode(Knowledge entity);

    /**
     * <p>浏览量加一</p>
     * <p>注意：方法名称特意不以update结尾，因为不需要进入mybatis拦截器</p>
     *
     * @author 何启谦
     * @param entity 知识库对象
     * @return
     */
    void increasePageviews(Knowledge entity);

    /**
     * 查询知识库文章各类型总数
     * @param record 知识库对象
     * @return List Knowledge
     * @throws Exception
     */
    public List<Knowledge> queryKnowledgeTypeNum(Knowledge record) throws Exception;


    /**
     * APP 查询知识库文章各类型总数
     * @author Tipor
     * @param record
     * @return
     * @throws Exception
     */
    public List<Knowledge> queryAppKnowledgeTypeNum(Knowledge record);

    /**
     * 修改浏览量、阅读人数、收藏数、点赞数
     *
     * @author ouyangzhenqiang
     * @date 2019/03/06 22:11
     * @param knowledge 知识库对象
     */
    void updateNum(Knowledge knowledge) throws Exception;

    /**
     * 模糊查询标题,内容
     * @author 朱泊阳
     * @param record
     * @return
     * @throws Exception
     */
    public List<Knowledge> queryKnowledgeByExamplePage(Knowledge record);

    /**
     * <p>浏览量pv字段加一，非pageview字段</p>
     * <p>注意：方法名称特意不以update结尾，因为不需要进入mybatis拦截器</p>
     *
     * @author 姚润发
     * @param id 知识库对象id
     * @return
     */
    int increasePV(Long id);
}
